package com.zizy.healthexpert.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.zizy.healthexpert.Database.MyDataBase;
import com.zizy.healthexpert.Database.MyDatabase_DishesRecords;
import com.zizy.healthexpert.R;

import java.util.List;

/**
 * Created by Zizy on 2014/7/22.
 */
public class listHistoryAdapter extends ArrayAdapter {
    private Context context;
    private int res;


    public listHistoryAdapter(Context context, int resource, List objects) {
        super(context, resource, objects);
        this.context=context;
        this.res=resource;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewGroup viewGroup=(ViewGroup) View.inflate(context, res, null);//inflate
        History item=(History)getItem(position);
        /*get view*/
        TextView txtHistoryDate=(TextView )viewGroup.findViewById(R.id.txtHistoryDate);
        TextView txtHistoryDishesName=(TextView )viewGroup.findViewById(R.id.txtHistoryFoodName);

        /*set view*/
        txtHistoryDate.setText(item.date);
        txtHistoryDishesName.setText(item.names);
        return viewGroup;


    }

    public static  class History{
        String names;
        String date;

        public History(String names, String date) {
            this.names = names;
            this.date = date;
        }

    }


}
